import React from 'react';
import { inject, observer } from 'mobx-react';
import { Modal } from 'antd';
import { WeaLocaleProvider } from 'ecCom';

import { WeaThemeCenter } from 'weaPortalPublic';

const getLabel = WeaLocaleProvider.getLabel;

@inject('portalThemeStore')
@observer
class E8LeftMenuBottom extends React.Component {
  constructor(props) {
    super(props);
    this.onShowThemeCenter = this.onShowThemeCenter.bind(this);
  }

  render() {
    const { portalThemeStore } = this.props;

    return (
      <div className="e8left-lmb">
        <WeaThemeCenter ecId={`${(this && this.props && this.props.ecId) || ''}_WeaThemeCenter@z3a5cq`} ref="WeaThemeCenter" />
        <div className="e8left-lmb-item e8left-lmb-personal" onClick={() => portalThemeStore.onLoadMain({ mobxrouteurl: '/customsetting' })} />
        <div className="e8left-lmb-item e8left-lmb-password" onClick={() => portalThemeStore.onLoadMain({ mobxrouteurl: '/hrm/password' })} />
        <div className="e8left-lmb-item e8left-lmb-skin" onClick={this.onShowThemeCenter} />
      </div>
    );
  }

  onShowThemeCenter() {
    const { portalThemeStore } = this.props;
    const { themeInfo = {} } = portalThemeStore;

    if (themeInfo.themeAppoint) {
      Modal.confirm({
        title: getLabel(15172, '系统提示'),
        content: getLabel(126325, '分部已指定主题模板，不能修改!'),
      });
    } else {
      this.refs.WeaThemeCenter.onShow();
    }
  }
}

export default E8LeftMenuBottom;
